﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title>Test</title>
        <style type="text/css">
        #introduction
        {
            background-color: #e1e1e1;
            font-size: 12px;
            margin: 5px;
            padding: 5px;
            clear: both;
        }
        </style>
		<script type="text/javascript">
        var dojoConfig = {
            baseUrl: "",
            tlmSiblingOfDojo: false,
            //packages: [
                //{ "name": "jquery", "location": 'modules', main: 'jquery-3.3.1.min' },
            //    { "name": "axios", "location": "modules", main: "axios.min" },
            //],
            paths: {
                'axios': 'modules/axios.min',
                'jquery': 'modules/jquery-3.3.1.min',
                'jquery.cookie': 'modules/jquery.cookie'
            },
            shim: {
                'jquery.cookie': { 'deps': ['jquery'] }
            }
        };
		</script>
		<script data-dojo-config="async: true" src="dojo.js"></script>
		
    </head>
    <body>
		<p>用户名： <input type="text" id="username" value="EG152500审核" />
		密码： <input type="text" id="userpass" value="111111" />
        <input type="button" id="testauth" value="用户登录"/> <div id='jg'></div>
		<input type="button" id="testwzapi" value="testwzapi"/>
		<input type="button" id="reguser" value="注册用户"/>
		<input type="button" id="UpdateUserSys" value="修改用户操作的系统"/>
		<input type="button" id="UpdateUserRol" value="修改用户操作的权限"/>
		</p>
		<p>
			<input type="button" value="地面调查返回初始化信息" id="egsinit" />
			<input type="button" value="监测点名称" id="seletejcmc" />
			<input type="button" value="监测子站名称" id="seletejczzmc" />
			<input type="button" value="验证监测点今年数据是否录入" id="Validatejcmc" />
			<input type="button" value="存储样地信息" id="Creatyd" />
			<input type="button" value="修改样地信息" id="Updateyd" />
			<input type="button" value="删除样地信息" id="Deleteyd" />
			<input type="button" value="查询样地信息" id="Selectyd" />
			<input type="button" value="样地评价信息录入" id="ydEvalInsert" />
			<input type="button" value="样地评价信息查询" id="ydEvalSelect" />
		</p>
		<p>
			<input type="button" value="添加草本样方" id="AddGrass" />
			<input type="button" value="修改草本样方" id="UpdateGrass" />
			<input type="button" value="删除草本样方" id="DeleteGrass" />
			<input type="button" value="查询草本样方" id="SelectGrass" />
		</p>
		<p>
			<input type="button" value="添加灌木样方" id="addShrub" />
			<input type="button" value="修改灌木样方" id="updateShrub" />
			<input type="button" value="删除灌木样方" id="DeleteShrub" />
			<input type="button" value="查询灌木样方" id="SelectShrub" />
		</p>
		<p>
			<input type="button" value="添加频度样方" id="addFrequency" />
			<input type="button" value="修改频度样方" id="updateFrequency" />
			<input type="button" value="删除频度样方" id="DeleteFrequency" />
			<input type="button" value="查询频度样方" id="SelectFrequency" />
		</p>
		<p>
			<p>
			WFSTATE:<input type="text" id="WFSTATE" value="1" />'1或2'  --流程处理标志：1是提交审核；2是退回</br>
			GEMPOINTID:<input type="text" id="GEMPOINTID" value="152500-008" /> --样地编号</br>
			SAMPLEPLOTID:<input type="text" id="SAMPLEPLOTID" value="152500-008-2018" />--样地对应当前年度编号</br>
			GEMNAME:<input type="text" id="GEMNAME" value="海流特围栏外" /> --监测点名称----新巴尔虎右旗大庆路与贝尔苏木十字路口西侧</br>
			AUDITROLEID:<input type="text" id="AUDITROLEID" value="R10301" /> --当前用户权限</br>
			AUDITSTATEDM:<input type="text" id="AUDITSTATEDM" value="1003" />  --审核状态代码</br>
			AUDITSTATE:<input type="text" id="AUDITSTATE" value="提交审核" />  --审核状态名称</br>
			AUDITIDEA:<input type="text" id="AUDITIDEA" value="" /> --审核意见</br>
			AUDITFEILD:<input type="text" id="AUDITFEILD" value="" /> --问题字段</br>
			FLOWNODEID:<input type="text" id="FLOWNODEID" value="" /> --审核流程节点id：如果流程节点为空说明为新增</br>
			VERSION:<input type="text" id="VERSION" value="" /> --审核流程的时间戳</br>
			<!--SUPERIORAUDITUSERID:<input type="text" id="SUPERIORAUDITUSERID" value="" /> --回退的用户id</br>
			SUPERIORAUDITUSERNAME:<input type="text" id="SUPERIORAUDITUSERNAME" value="" /> --回退的用户名</br>
			FLOWNUMBER:<input type="text" id="FLOWNUMBER" value="" /> --当前样地的流程节点</br-->
			</p>
			<p>
			登陆用户token：<input type="text" id="logintoken" size="90" value="" /></br>
			</p>
			<input type="button" value="提交审核" id="SubAudit" />
			<input type="button" value="查询用户审核权限" id="AuditingSearch" />
			<input type="button" value="查询已经审核内容" id="AlreadyAuditing" />
			<input type="button" value="查询审核内容" id="waitAuditing" />
		</p>
		<p>
			输入计算的年度:<input type="text" id="SYEAR" value="2018" /><input type="text" id="TYPE" value="CB" />
			<input type="button" value="查询重要值计算的样地" id="TImportantValuePoint" />
			输入监测年度编号:<input type="text" id="POINTID" value="152500-003-2018-CB" />
			<input type="button" value="查询重要值样地表格" id="ImportantValueTable" />
			<input type="button" value="修改优势种" id="UpdateDominantSpecies" />
		</p>
		<p>
			websocket计算重要值
			<button class="btn btn-primary" type="button" id="contentButton">链接</button>
			<input type="text" class="form-control" size="88" value="{'CalculationType':'CBYD','GrassId':['152500-003-2018','152500-017-2018','152500-007-2018']}" id="messageText">
            <button class="btn btn-primary" type="button" id="messageButton">发送</button>
			<div class="col-lg-8" id="mainThread">
                  <h2>Discussion</h2>
              </div>
		</p>
		<input type="button" value="test" id="test" />
			<p>指定文件名： <input id="fileupload-tools-txt" type="text" name="filename" value="" /></p>
			<p> 上传文件： <input id="fileupload-tools" type="file" name="file" multiple="multiple"/></ p>
            <input type="button" value="上传" id="ajaxUpload" />
    </body>
	<script type="text/javascript">
        require([
        "jquery",
        'modules/ApiClient',
		'modules/egstools',
		'modules/auditTools',
		'modules/config',
		'modules/chatServer',
		 "dojo/dom","dojo/on", "dojo/domReady!"
		], function ($,ApiClient,egstools,auditTools,config,chatServer,dom,on) {
			var tokenid = "";
			var stoken = "";
			$("#testauth").bind('click', function () {
                alert('zzh');
				var json_params={
					UserName:$("#username").val(),
					PasswordHash:$("#userpass").val()//,
					//client_id:'password_client'//'password_client'
				}
				alert(config.USWEBAPI);
				ApiClient.post(config.USWEBAPI+'Auth/login',json_params,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						$('#jg').append("登陆状态: "+reValues.data.reMessage+"<br/>");
						$('#jg').append("token: "+reValues.data.jwt+"<br/>");
						$('#jg').append("token-id: "+reValues.data.sid+"<br/>");
						tokenid = reValues.data.sid;
						stoken = reValues.data.jwt;
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
            });
			$("#reguser").bind('click',function(){
				var json_params={
                    UserName: 'test1',
                    PasswordHash: '111111',
                    RealName: '达旗录入',
                    WorkUnit: '工作单位',
                    IncumbentPost: '现职务',
                    PresentAddress: '达茂旗',
                    ZipCodeNumber: '邮编',
                    SeatNumber: '座机号码',
                    PhoneNumber: '手机号码',
                    MailBox: '电子邮箱',
                    QQNumber: 'QQ号码'
                }
				ApiClient.post(config.USWEBAPI+'Reg/User',json_params,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
			});
			//UpdateUserRol
			$("#UpdateUserRol").bind('click',function(){
				var json_params={
					egdbrol:[
						{NAVID:"R101",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R102",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R10201",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R10202",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"}
					],
					ersdbrol:[
						{NAVID:"R101",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R101",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R103",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R10301",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"}
					],
					wzrol:[
						{NAVID:"R101",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R10101",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R102",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"},
						{NAVID:"R10201",USERID:"e6e88030-3daf-4c63-a762-b8bf91f2b60a"}
					]
                }
				ApiClient.post(config.USWEBAPI+'Rol/UpdateRolList',json_params,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
			});
			//UpdateUserSys
			$("#UpdateUserSys").bind('click',function(){
				var json_params=[
				{
                    tblName:'egdb',
					Commandtype:'add',
					uid:'e6e88030-3daf-4c63-a762-b8bf91f2b60a',
					UserName:'test1',
					WorkUnit:'test1',
					WorkUnitDM:'EG152900',
					SECURITYSTAMP:'1'
                },{
                    tblName:'ersdb',
					Commandtype:'add',
					uid:'e6e88030-3daf-4c63-a762-b8bf91f2b60a',
					UserName:'test1',
					WorkUnit:'test1',
					WorkUnitDM:'EG152900',
					SECURITYSTAMP:'1'
                },{
                    tblName:'wz',
					Commandtype:'add',
					uid:'e6e88030-3daf-4c63-a762-b8bf91f2b60a',
					UserName:'test1',
					WorkUnit:'test1',
					WorkUnitDM:'EG152900',
					SECURITYSTAMP:'1'
                },{
                    tblName:'rsdb',
					Commandtype:'add',
					uid:'e6e88030-3daf-4c63-a762-b8bf91f2b60a',
					UserName:'test1',
					WorkUnit:'test1',
					WorkUnitDM:'EG152900',
					SECURITYSTAMP:'1'
                }
				];
				var surl = config.USWEBAPI+'Rol/UpdateUser';
				alert(surl)
				ApiClient.post(surl,json_params,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
			});
			$("#seletejcmc").bind('click',function(){
				egstools.userGetGempoint(stoken);
			});
			$("#egsinit").bind('click',function(){
				//76d93869-7433-47a2-9310-5a300bd511aa
				alert(tokenid);
				egstools.egsinit(tokenid);
			});
			$("#Validatejcmc").bind('click',function(){
				egstools.Validatejcmc(stoken);
			});
			$("#Creatyd").bind('click',function(){
				egstools.Creatyd(stoken);
			});
			$("#Updateyd").bind('click',function(){
				egstools.Updateyd(stoken);
			});
			$("#Deleteyd").bind('click',function(){
				egstools.Deleteyd(stoken);
			})
			//Selectyd
			on(dom.byId("Selectyd"),"click",function(evt){
				alert(dom.byId("Selectyd").id);
				egstools.Selectyd(stoken)
			});
			//http://localhost:9100/api/wz.api/test
			$("#testwzapi").bind('click', function () {
                alert('zzh');
				var json_params={
					cpage:'1',
					pageSize:'12',
					//total:'jczgroup_client'//'password_client'
					total:'0',
					WZT:{
						WZMC:'',//'毛',
						SDM:'1010001000100010001'
					}
				}
				ApiClient.post(config.WZWEBAPI+'SpeciesSearch',json_params,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
                
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
            });
			$("#ajaxUpload").click(function () {
                var json_params = {};
				json_params.files = document.getElementById('fileupload-tools').files;
				json_params.params = {filetype:'AscSource',filetime:'2018'};
				var param = new FormData();
				if(json_params.files.value == "") {
					alert("上传文件不能空");
					return ;
				}
				for(var i = 0; i< json_params.files.length; i++){//v==value　为arr项，i==index　为arr索引
					$('body').append("fileArray: "+json_params.files[i].name+"<br/>");
					param.append("fileArray"+i,json_params.files[i]);   // 文件对象
				}
				/*for(var key in json_params.params){
					$('body').append(key+": "+json_params.params[key]+"<br/>");
					param.append(key, json_params.params[key]);
				} */
				//param.append('file', uploadInput.files[0]);
				ApiClient.postfile(config.WZWEBAPI+'Upload',param, '').then(function (resValue) {
					//alert("zzh");
					//alert(resValue.data);
					console.log(resValue);
					resValue.data.forEach(value => {
　　					console.log('forEach遍历:'+'--'+value);
						$('body').append("return: "+value.name+"-------------"+value.state+"<br/>");
					})
					//refunc(resValue);
				});
            });
			on(dom.byId("AddGrass"), "click", function(evt){
				egstools.addGrass(stoken)
			}); 
			on(dom.byId("UpdateGrass"), "click", function(evt){
				egstools.UpdateGrass(stoken)
			});
			on(dom.byId("DeleteGrass"), "click", function(evt){
				egstools.DeleteGrass(stoken)
			});
			on(dom.byId("SelectGrass"), "click", function(evt){
				egstools.SelectGrass(stoken)
			});
			on(dom.byId("addShrub"), "click", function(evt){
				egstools.addShrub(stoken)
			});
			on(dom.byId("updateShrub"), "click", function(evt){
				egstools.updateShrub(stoken)
			});
			on(dom.byId("DeleteShrub"), "click", function(evt){
				egstools.DeleteShrub(stoken)
			});
			on(dom.byId("SelectShrub"), "click", function(evt){
				egstools.SelectShrub(stoken)
			});
			
			on(dom.byId("addFrequency"), "click", function(evt){
				egstools.addFrequency(stoken)
			});
			on(dom.byId("updateFrequency"), "click", function(evt){
				egstools.updateFrequency(stoken)
			});
			on(dom.byId("DeleteFrequency"), "click", function(evt){
				egstools.DeleteFrequency(stoken)
			});
			on(dom.byId("SelectFrequency"), "click", function(evt){
				egstools.SelectFrequency(stoken)
			});
			
			on(dom.byId("SubAudit"),"click", function(evt){
				alert(dom.byId("WFSTATE").value);
				var json_params={
					WFSTATE:dom.byId("WFSTATE").value,  //--流程处理标志：1是提交审核；2是退回
					GEMPOINTID:dom.byId("GEMPOINTID").value, //--样地编号
					SAMPLEPLOTID:dom.byId("SAMPLEPLOTID").value,  //--样地对应当前年度编号
					GEMNAME:dom.byId("GEMNAME").value, //--监测点名称----新巴尔虎右旗大庆路与贝尔苏木十字路口西侧
					AUDITROLEID:dom.byId("AUDITROLEID").value, //--当前用户权限
					AUDITSTATEDM:dom.byId("AUDITSTATEDM").value,  //--审核状态代码
					AUDITSTATE:dom.byId("AUDITSTATE").value,  //--审核状态名称
					AUDITIDEA:dom.byId("AUDITIDEA").value, //--审核意见
					AUDITFEILD:dom.byId("AUDITFEILD").value, //--问题字段
					FLOWNODEID:dom.byId("FLOWNODEID").value, //--审核流程节点id：如果流程节点为空说明为新增
					VERSION:dom.byId("VERSION").value, //--审核流程的时间戳
					//SUPERIORAUDITUSERID:dom.byId("SUPERIORAUDITUSERID").value, //--审核流程的时间戳
					//SUPERIORAUDITUSERNAME:dom.byId("SUPERIORAUDITUSERNAME").value //--审核流程的时间戳
				}
				var gtoken = dom.byId("logintoken").value;
				auditTools.SubAudit(json_params, gtoken)
			});
			on(dom.byId("AuditingSearch"),"click",function(evt){
				alert(dom.byId("AuditingSearch").id);
				auditTools.AuditingSearch(stoken)
			});
			
			on(dom.byId("AlreadyAuditing"),"click",function(evt){
				alert(dom.byId("AlreadyAuditing").id);
				auditTools.AlreadyAuditing(stoken)
			});
			
			on(dom.byId("waitAuditing"),"click",function(evt){
				alert(dom.byId("waitAuditing").id);
				auditTools.waitAuditing(stoken)
			});
			
			on(dom.byId("TImportantValuePoint"),"click",function(evt){
				alert(dom.byId("TImportantValuePoint").id);
				//SYEAR
				var syear = dom.byId("SYEAR").value;
				var stype = dom.byId("TYPE").value;
				var json_params={
					stype:dom.byId("TYPE").value,  //--流程处理标志：1是提交审核；2是退回
					syear:dom.byId("SYEAR").value, //--样地编号
				}
				auditTools.TImportantValuePoint(stoken,json_params)
			});
			//ImportantValueTable
			on(dom.byId("ImportantValueTable"),"click",function(evt){
				alert(dom.byId("ImportantValueTable").id);
				//SYEAR
				var ydid = dom.byId("POINTID").value;
				auditTools.ImportantValueTable(stoken,ydid);
			});
			on(dom.byId("contentButton"),"click",function(evt){
				chatServer.init();
			});
			on(dom.byId("messageButton"),"click",function(evt){
				var ydid = dom.byId("messageText").value;
				chatServer.sendMessage(ydid);
			});
			on(dom.byId("UpdateDominantSpecies"),"click",function(evt){
				auditTools.UpdateDominantSpecies(stoken);
			});
			on(dom.byId("ydEvalInsert"),"click",function(evt){
				alert(stoken);
				egstools.ydEvalInsert(stoken);
			});
			//ydEvalSelect
			on(dom.byId("ydEvalSelect"),"click",function(evt){
				alert(stoken);
				egstools.ydEvalSelect(stoken);
			});
			on(dom.byId("seletejczzmc"),"click",function(evt){
				alert(stoken);
				egstools.seletejczzmc(stoken);
			});
		});
	</script>
</html>